﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace pGrid
{

  public partial class Auction : Window
  {
    private int yourBet;
    private int highestBet;
    private string highestBetPlayer;
    private string playerName;
   
    private bool fold_press;



    public Auction(PowerStation station, string player_name, string higher_bet)
    {
      yourBet = station.Cost + 1;
      highestBet = station.Cost;
      highestBetPlayer = higher_bet;
      playerName = player_name;
      InitializeComponent();
      this.player_name_label.Content = player_name;
      this.highest_bet_label2.Content = highestBetPlayer;
      this.price_label2.Content =  highestBet.ToString();
      this.price_textbox.Text = yourBet.ToString();
      this.image1.Source = station.Pic;
    }

    public int NewPrice
    {
      get
      {
        return yourBet;
      }
      set
      {
        yourBet = value;
      }
    }
    public bool Fold
    {
      get
      {
        return this.fold_press;
      }
    }
    public string HighestBetName
    {
      get
      {
        return highestBetPlayer;
      }
    }
    private void bet_button_Click(object sender, RoutedEventArgs e)
    {
      int price = Convert.ToInt32(this.price_textbox.Text.ToString());
      this.yourBet = price;
      this.highestBetPlayer = this.playerName;
      this.fold_press = false;
      this.Close();
    }

    private void fold_button_Click(object sender, RoutedEventArgs e)
    {
      yourBet--;
      this.fold_press = true;
      this.Close();
    }

    private void price_textbox_TextChanged(object sender, TextChangedEventArgs e)
    {
      if (this.price_textbox.Text == "") return;
      int yourBet = Convert.ToInt32(this.price_textbox.Text.ToString());
      if (yourBet > highestBet)
        this.bet_button.IsEnabled = true;
      else
        this.bet_button.IsEnabled = false;
    }
  }
}
